package com.xbts.screen.controller.workshop;

import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.core.web.domain.BaseHistogramResult;
import com.xbts.common.core.web.domain.BasePieChartResult;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.screen.domain.workshop.vo.*;
import com.xbts.screen.service.IPlatingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 电镀车间Controller
 */
@Api(tags = "电镀车间")
@RestController
@RequestMapping("/plating")
public class PlatingController extends BaseController {


    @Autowired
    private IPlatingService platingService;

    /**
     * 实时达成率1
     */
    @ApiOperation("实时达成率")
    @RequiresPermissions("workshop:plating:realTimeAchievementRate")
    @GetMapping("/realTimeAchievementRate")
    public AjaxResult realTimeAchievementRate(){
        RealTimeAchievementRateVO vo = platingService.realTimeAchievementRate();
        return success(vo);
    }
    /**
     * 近10天达成率1
     */
    @ApiOperation("近10天达成率")
    @RequiresPermissions("workshop:plating:tenDaysAchievementRate")
    @GetMapping("/tenDaysAchievementRate")
    public AjaxResult tenDaysAchievementRate(){
        BaseHistogramResult result = platingService.tenDaysAchievementRate();
        return success(result);
    }
    /**
     * 达成率根据时间分组1
     */
    @ApiOperation("达成率根据时间分组")
    @RequiresPermissions("workshop:plating:achievementRateGroupByTimeType")
    @GetMapping("/achievementRateGroupByTimeType")
    public AjaxResult achievementRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = platingService.achievementRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 水单耗
     */
    @ApiOperation("水单耗")
    @RequiresPermissions("workshop:plating:waterUnitConsume")
    @GetMapping("/waterUnitConsume")
    public AjaxResult waterUnitConsume(){
        BaseHistogramResult result = platingService.waterUnitConsume();
        return success(result);
    }
    /**
     * 电单耗
     */
    @ApiOperation("电单耗")
    @RequiresPermissions("workshop:plating:electricityUnitConsume")
    @GetMapping("/electricityUnitConsume")
    public AjaxResult electricityUnitConsume(){
        BaseHistogramResult result = platingService.electricityUnitConsume();
        return success(result);
    }
    /**
     * 排产计划1
     */
    @ApiOperation("排产计划")
    @RequiresPermissions("workshop:plating:productionSchedule")
    @GetMapping("/productionSchedule")
    public AjaxResult productionSchedule(){
        List<ProductionScheduleVO> vos = platingService.productionSchedule();
        return success(vos);
    }
    /**
     * 周转率
     */
    @ApiOperation("周转率")
    @RequiresPermissions("workshop:plating:turnoverRate")
    @GetMapping("/turnoverRate")
    public AjaxResult turnoverRate(){
        BaseHistogramResult vo = platingService.turnoverRate();
        return success(vo);
    }
    /**
     * 周转率根据时间类型分组
     */
    @ApiOperation("周转率根据时间类型分组")
    @RequiresPermissions("workshop:plating:turnoverRateGroupByTimeType")
    @GetMapping("/turnoverRateGroupByTimeType")
    public AjaxResult turnoverRateGroupByTimeType(){
        StatisticalRateGroupByTimeVO vo = platingService.turnoverRateGroupByTimeType();
        return success(vo);
    }
    /**
     * 合格率1
     */
    @ApiOperation("合格率")
    @RequiresPermissions("workshop:plating:passRate")
    @GetMapping("/passRate")
    public AjaxResult passRate(){
        PassRateVO vo = platingService.passRate();
        return success(vo);
    }
    /**
     * 不良统计1
     */
    @ApiOperation("不良统计")
    @RequiresPermissions("workshop:plating:badStatistics")
    @GetMapping("/badStatistics")
    public AjaxResult badStatistics(){
        List<BasePieChartResult> resultList = platingService.badStatistics();
        return success(resultList);
    }
    /**
     * 报废率1
     */
    @ApiOperation("报废率")
    @RequiresPermissions("workshop:plating:scrapRate")
    @GetMapping("/scrapRate")
    public AjaxResult scrapRate(){
        ScrapRateVO vo = platingService.scrapRate();
        return success(vo);
    }
    /**
     * 报废统计1
     */
    @ApiOperation("报废统计")
    @RequiresPermissions("workshop:plating:scrapStatistics")
    @GetMapping("/scrapStatistics")
    public AjaxResult scrapStatistics(){
        List<BasePieChartResult> resultList = platingService.scrapStatistics();
        return success(resultList);
    }
    /**
     * 一次合格率
     */
    @ApiOperation("一次合格率")
    @RequiresPermissions("workshop:plating:firstPassRate")
    @GetMapping("/firstPassRate")
    public AjaxResult firstPassRate(){
        RealTimeAchievementRateVO vo = platingService.firstPassRate();
        return success(vo);
    }
    /**
     * 二次合格率
     */
    @ApiOperation("二次合格率")
    @RequiresPermissions("workshop:plating:secondaryPassRate")
    @GetMapping("/secondaryPassRate")
    public AjaxResult secondaryPassRate(){
        RealTimeAchievementRateVO vo = platingService.secondaryPassRate();
        return success(vo);
    }
    /**
     * 料号批次合格率记录1
     */
    @ApiOperation("料号批次合格率记录")
    @RequiresPermissions("workshop:plating:passRateRecord")
    @GetMapping("/passRateRecord")
    public AjaxResult passRateRecord(){
        List<PassRateRecordVO> resultList = platingService.passRateRecord();
        return success(resultList);
    }
}
